﻿using Glorysoft.EAP.Core.Entities.DB.Contract;
using System;
using System.Collections.Generic;
using System.Text;

namespace Glorysoft.EAP.Core.Entities.DB.Service
{
    public class RPT_MONITOR_TIME_HISTORYService //: FreeSqlContext//, IRPT_MonitorTimeService
    {
        public static int Delete(int id)
        {
            //return base.FreeSqlConnect().Delete<RPT_MSG_HISTORY>(id).ExecuteAffrows();
            return FreeSqlContext.Delete<RPT_MONITOR_TIME_HISTORY>(id);
        }

        public static int Insert(RPT_MONITOR_TIME_HISTORY entity)
        {
            return FreeSqlContext.Insert<RPT_MONITOR_TIME_HISTORY>(entity);
        }

        public static IList<RPT_MONITOR_TIME_HISTORY> SelectAll()
        {
            return FreeSqlContext.SelectAll<RPT_MONITOR_TIME_HISTORY>();
        }

        public static RPT_MONITOR_TIME_HISTORY SelectById(int id)
        {
            return FreeSqlContext.SelectById<RPT_MONITOR_TIME_HISTORY>(id);
        }
        public static RPT_MONITOR_TIME_HISTORY SelectByWeekID(string weekid)
        {
            return FreeSqlContext.FreeSqlConnect.Select<RPT_MONITOR_TIME_HISTORY>().Where(t => t.WEEKID == weekid).First();

        }

        public static int Update(int count,string weekid,string monitortest)
        {
            return FreeSqlContext.FreeSqlConnect.Update<RPT_MONITOR_TIME_HISTORY>().Set(a => a.COUNT, count).Set(a => a.REMINDTIME, DateTime.Now).Set(a => a.MONITORTEST, monitortest).Where(a => a.WEEKID == weekid).ExecuteAffrows(); ;
        }
    }
}
